<?php
$version = Zend_Registry::get('version');
$this->pollForm->setEditor(Zend_Registry::get('config')->eicra->params->domain.$this->baseUrl());
$this->pollForm->getEditor();
echo $this->headScript()->appendFile($this->baseUrl().'/js/jquery/tree/javascripts/jquery.treeTable.js');	
echo $this->headScript()->appendFile($this->baseUrl().'/js/jquery/table-sorter/jquery.dataTables.js');

$global_conf = Zend_Registry::get('global_conf');
$currency = new Zend_Currency($global_conf['default_locale']);

$frontController = Zend_Controller_Front::getInstance();
$param_group_id = $frontController->getRequest()->getParam('group_id');
?>

<script type="text/javascript">
function calender(id)
{
	$("#"+id).datepicker({
		showOn: 'button',
		buttonImage: 'application/modules/Administrator/layouts/scripts/images/common/calendar.png',
		buttonImageOnly: true,
		showAnim: 'slide',
		buttonText: 'Calender',
		dateFormat:'yy-mm-dd',
		autoSize:false,
		showButtonPanel:false,
		changeMonth: true,
		changeYear: true
	});
	$("img[class='ui-datepicker-trigger']").each(function()
	 { 
	  	$(this).attr('style', '');
	 });
}
$(document).ready(function() {
	floatingbar('#floatingbar',"#button_top_bar",null);
	categoryTreeGen();
	imageThumbnil();	
	calender('start_date');
	calender('end_date');
	deleteFiles("<?php echo $this->translator->translator('gallery_img_main','', 'gallery'); ?>", "<?php echo $this->translator->translator('gallery_img_related','', 'gallery'); ?>", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'remove' ), 'adminrout',    true) ?>", "<?php echo $this->translator->translator('common_delete_title'); ?>");
	
	addDynamicField();	
	/****************************Sorting Table Start*********************/
	var oTable = $("#sortTable").dataTable({
				"bPaginate": false,
				"bLengthChange": true,
				"bSearchable": false,
				"bFilter": false,
				"bSort": false,
				"bInfo": false,
				"bAutoWidth": true,
				"bProcessing": false,
				"bSortClasses": true,
				"bStateSave": false,
				"bServerSide": false,
				"aaSorting": [[ 2, "asc" ]],
				"oLanguage" : { "sSearch": "<?php echo $this->translator->translator('jquery_filter'); ?>" }
			}); 	
	
	$('td', oTable.fnGetNodes()).hover( function() {		
		$(this).parents("tr:first").children('td').addClass( 'highlighted' );
	}, function() {
		$('td.highlighted').removeClass('highlighted');
	} );
	
	/* Get the rows which are currently selected */
	function fnGetSelected( oTableLocal )
	{
		var aReturn = new Array();
		var aTrs = oTableLocal.fnGetNodes();
		
		for ( var i=0 ; i<aTrs.length ; i++ )
		{
			if ( $(aTrs[i]).hasClass('row_selected') )
			{
				aReturn.push( aTrs[i] );
			}
		}
		return aReturn;
	}
	
	lastClassAdd(oTable);
	
	function openMsgDialog(msg)
	{
		$('#dialog_msg').html(msg).dialog({
			autoOpen: true,
			modal: true,
			show: 'explode',
			resizable: true,				
			buttons: [{ text: "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, 'UTF-8'); ?>", click: function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } } ],
			open: function(event, ui)
				 {
					setTimeout(function() 
					{									
						if($('#' + event.target.id).dialog('isOpen'))
						{
							$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
						}
					}, 10000);
				  }
		});
	}
	
	$("#upload-form").dialog({
		autoOpen: false,
		width: 750,
		height: 610,
		show: 'fade',			
		modal: true
	});	
	
	$('a.upload_btn').click(function() {
		$("#i-upload-form").attr("src", '');
		$("#i-upload-form").html('');
		
		var group_id = $("#group_id").val();
		$('input[name="primary_id_field_value"]').val(group_id);
				
		var file_content = $('input[name="thumb"]').val();
		$('input[name="file_content"]').val(file_content);	
		if(group_id != null && group_id != "")
		{
			$("#popupForm").attr("action", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action' => 'manager' ), 'adminrout',    true) ?>");			
			$('#upload-form').dialog('open');
			$('#popupForm').submit();
		}
		else
		{
			msg = '<?php echo $this->translator->translator("group_id_selected_err"); ?>';
			openMsgDialog(msg);
		}
	});
	
	$('a.delete_btn').click(function() {
		var self = this;
		$("#dialog-confirm").html("<?php echo addslashes($this->translator->translator('poll_answer_delete_confirm')); ?>").dialog({
			resizable: true,
			width:400,
			modal: true,
			show: 'fade',
			hide: 'explode',
			buttons: [{
							text: '<?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?>', 
							click: function() {
								deleteThis(self);
								$(this).dialog('close');
							}
						},
						{
							text: '<?php echo html_entity_decode($this->translator->translator("common_cancel"), ENT_QUOTES, "UTF-8"); ?>', 
							click: function() {
								$(this).dialog('close');							
							}
					}]
		});
		
	});
	
	$('a.edit_btn').click(function() {
		var self = this;
		$(self).hide();	
		$(self).parents("li:first").children("a:nth-child(2)").show();
		$(self).parents("li:first").children("a:nth-child(3)").show();
		var answer = $(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").text();
			answer = jQuery.trim(answer);	
		$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").html('<input type="text" value="'+answer+'" />');
	});
		
	$('a.save_btn').click(function() {
		var self = this;
		var rel = $(self).attr('rel');
		
		var answer = $(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").children("input:nth-child(1)").val();
			answer = jQuery.trim(answer);
		$.ajax({
			url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'edit' ), 'adminrout',    true) ?>",
			type: 'POST',
			data: { id: rel, content: answer},
			beforeSend: function(){						
				$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
			 },
			success: function(response) 
			{
				//alert(response);
				var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					$(self).hide();	
					$(self).parents("li:first").children("a:nth-child(3)").hide();
					$(self).parents("li:first").children("a:nth-child(1)").show();
					$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").html(answer);
				}
				else
				{
					$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").html('<input type="text" value="'+answer+'" />');
					openMsgDialog(json_arr.msg);
				}						
			}
		});
	});
		
	$('a.cancel_btn').click(function() {
		var self = this;
		$(self).hide();	
		$(self).parents("li:first").children("a:nth-child(2)").hide();
		$(self).parents("li:first").children("a:nth-child(1)").show();
		var answer = $(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").children("input:nth-child(1)").val();
		answer = jQuery.trim(answer);	
		$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").children("td:nth-child(1)").html(answer);
	});
	
	function deleteThis(self)
		{
			var arr = $(self).attr('rel').split('_');
			$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'delete' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { id: arr[0]},
				 beforeSend: function(){
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
					 },
				 success: function(response) 
				 {
					//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").addClass('row_selected');
						var oTables = $('#sortTable').dataTable();
						var anSelected = fnGetSelected( oTables );
						oTables.fnDeleteRow( anSelected[0] );
					}
				 }
			});
		}
	
	$('a.publish_btn').click(function() {
		var self = this;
		$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" border="0" height="17" />');
		var arr = $(self).attr('rel').split('_');
		$.ajax({
			 url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'publish' ), 'adminrout',    true) ?>",
			 type: 'POST',
			 data: { id: arr[0], paction: arr[1]},
			 success: function(response) 
			 {
			 	//alert(response);
			 	var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					if(json_arr.active == '1')
					{
						$(self).parents("td:first").parents("tr:first").children("td:nth-child(5)").html('<?php echo $this->translator->translator("common_published_language"); ?>');
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator("common_unpublish_title"); ?>" />').attr('rel',arr[0]+"_unpublish");
					}
					else
					{
						$(self).parents("td:first").parents("tr:first").children("td:nth-child(5)").html('<?php echo $this->translator->translator("common_unpublished_language"); ?>');
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif"  border="0" title="<?php echo $this->translator->translator("common_publish_title"); ?>" />').attr('rel',arr[0]+"_publish");
					}
			 	}
				else
				{
					openMsgDialog(json_arr.msg);
				}
			 }
		});
	});		
	
	$('a.select_file_btn').click(function() {		 
			var currentIFrame = $('#i-upload-form');
			var selected_files = currentIFrame.contents().find("input[name='selected_files']").val();
			var primary_file_field = currentIFrame.contents().find("input[name='primary_file_field']").val();
			var file_path	=	currentIFrame.contents().find("input[name='file_path']").val();
			var selected_files_arr = (selected_files != '') ? selected_files.split(',') : new Array();	
			if(selected_files_arr.length == '0')
			{
				var msg = '<?php echo $this->translator->translator("insert_selected_file_err"); ?>';				
				openMsgDialog(msg);
			}
			else
			{
				var img_path = file_path +'/'+ selected_files_arr[0]; 	
				var del_link = '<a href="javascript:void(0)" class="delete_image_lnk" rel="'+selected_files_arr[0]+'"><?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?></a>';						
				var img_code = '<div class="upload-img box"><span><span class="thumb"><img src="'+img_path+'" width="45" height="35" class="bdr" /></span><br /><br />'+del_link+'&nbsp;&nbsp;&nbsp;&nbsp;</span></div>';
				$('#selected_file_thumb').html(img_code);
				$('input[name="thumb"]').val(selected_files_arr[0]);
				$("#i-upload-form").attr("src", '');
				$("#i-upload-form").html('');
				$("#upload-form").dialog('option','hide','explode').dialog('close');
				deleteFiles("<?php echo $this->translator->translator('gallery_img_main','', 'gallery'); ?>", "<?php echo $this->translator->translator('gallery_img_related','', 'gallery'); ?>", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'remove' ), 'adminrout',    true) ?>", "<?php echo $this->translator->translator('common_delete_title'); ?>");	
				imageThumbnil();
			}
		});
	
	$('a.close_dialog_btn').click(function() {	
		$("#i-upload-form").attr("src", '');	 
		$("#upload-form").dialog('option','hide','explode').dialog('close');			
	});
		
	$('a.reset_btn').click(function() {			
		 resetFields();	
		 removeError();	
	});
	
	function resetFields()
	{
		$( "form" )[ 0 ].reset();		
		$('#selected_file_thumb').html('<?php if($this->pollForm->thumb->getValue()){ ?><span class="thumb"><img src="data/frontImages/poll/poll_thumb/<?php echo $this->pollForm->thumb->getValue(); ?>" width="45" height="35" /></span><?php } ?>');
		$('#category_id').val('<?php echo $this->pollForm->category_id->getValue(); ?>');
		$('#thumb').val('<?php echo $this->pollForm->thumb->getValue(); ?>');
		$('#categoryTree').html('<?php echo addslashes($this->categoryTree); ?>');
		$('#dataId').html('<?php echo addslashes($this->category_name)." (".$this->category_id.")"; ?>');		
		$('a.back_btn_link').attr('href','<?php echo $this->url( array("module" => "Poll","controller" => "backendpoll", "action"  => "list" ,"group_id" => $param_group_id), "adminrout",    true) ?>');
		$("#add_more").html();
		$("#add_more").html('<span class="select-btn" id="addMoreTitle"><a href="javascript:void(0)" class="add_ans_btn" rel="<?php echo $this->last_order; ?>"><span class="icon add"><?php echo $this->translator->translator("poll_answer_add_new"); ?></span></a></span><span id="add_data">&nbsp;</span>');
		var never_end = $("#end_date").attr('rel');
		if(never_end)
		{
			$("#end_date").attr('disabled','disabled');
		}
		categoryTreeGen();	
		imageThumbnil();
		addDynamicField();
	}
	
	function removeError()
	{
		$('#actionMessage').html('');
		
		var filename = '';
		var filevalue = '';		
		$.each($('form').serializeArray(), function(i, field) {	
				if(field.name.match(/\[\]$/))
				{
					var filearr = field.name.split('[]');
					filename = filearr[0];					
				}
				else
				{
					filename 	= 	field.name;
				} 			
				$('#'+filename).removeClass('ui-state-error');
				$('#'+filename+'_err').html('');									
		});				
	}
	
	function addError(key,errMsg)
	{
		var err_id = key+'_err';
		var field_name = key;
		$('#'+field_name).addClass('ui-state-error');
		$('#'+err_id).append(errMsg);
	}
	
	function openLoaderDialog()
	{
		$('#dialog_container').dialog({
					autoOpen: true,
					modal: true,
					show: 'explode',
					resizable: false,				
					open: function(event, ui)
						 {
						 	$("#progressbar").progressbar({
								value:100
				
							});							
						  }
				});
	}
	
	function closeLoaderDialog()
	{
		$('#dialog_container').dialog('option','hide','explode').dialog('close');
	}
	
	function getFormData()
	{
		var fieldObj = {};
		var filename = '';
		var filevalue = '';
		var poll_answer	= new Array(1);
		$.each($('form').serializeArray(), function(i, field) {	
			var count = 0;
			if(field.name.match(/\[\]$/) && count == 0)
			{
				$("input[name='poll_answer[]']").each(function(id,field) { 				
					poll_answer[id] 		= field.value;
				});
				var filename	= 	field.name.split('[]');
				fieldObj[filename[0]] = poll_answer;
				count++;
			}
			else
			{
				filename 	= 	field.name;
				filevalue 	= 	field.value;
				fieldObj[filename] = (tinyMCE.get(filename)) ? tinyMCE.get(filename).getContent() : filevalue;			
			}	
		});
		return fieldObj;
	}
	
	function sortAllOrder()
	{
		var order = new Array(); 
		var count = 0;
		$("#sortTable input:text").each(function() {
			order[count++] = $(this).val();
		});				
		order.sort(function(a,b){
			return a - b;
		});
		$("#sortTable input:text").each(function() {
			for(key in order)
			{
				// If current value is in sorted order key
				if($(this).val() == order[key])
				{
					// As array starts from 0
					newval = parseInt(key) + 1;
					$(this).val(newval);
					break;
				}
			}
		});
	}
	
	$('a.all_order_btn').click(function() {
		sortAllOrder();
		var self = this;
		var answer_order_str = '';
		var id_str = '';
		for(var i=0;i<$('input.answer_order_text').length;i++)
		{
			if(i == 0)
			{
				answer_order_str += $('input.answer_order_text:eq('+i+')').val();
				id_str += $('input.answer_order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
			else
			{
				answer_order_str += ','+$('input.answer_order_text:eq('+i+')').val();
				id_str += ','+$('input.answer_order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
		}
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'orderall' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { id_arr: id_str, answer_order_arr: answer_order_str},
				 beforeSend: function(){
					oTable.fnSettings().aoColumns[2].bSortable = false;
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" border="0" height="16" />');
				 },
				 success: function(response) 
				 {
				 	//alert(response);
					var json_arr = eval("("+response+")");
					openMsgDialog(json_arr.msg);
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" />');
					oTable.fnSettings().aoColumns[2].bSortable = true;
				 }
		});
	});
	
	$('a.up_btn').click(function() {
		var self = this;
		var arr = $(self).attr('rel').split('_');
		var prev_order = $(self).parents("td:first").children("input:first").val();		
		
		//sortAllOrder();
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'up' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { id: arr[0],answer_order: prev_order},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-animation.gif" border="0" />');
				 },
				 success: function(response) 
				 {
				 	//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						$(self).parents("td:first").children("input:first").val((prev_order-1));
						if(json_arr.id_arr != '' && json_arr.id_arr != null)
						{
							for(var i = 0; i < json_arr.id_arr.length; i++)
							{
								for(var j=0;j < $('a.up_btn').length ;j++)
								{
									var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');	
									if(arrUp[0] == json_arr.id_arr[i])	
									{										
										$('a.up_btn:eq('+j+')').parents("td:first").children("input:nth-child(1)").val(prev_order);
									}					
								}
							}							
						}						
					}
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" />');
				 },
				error: function(xhr, status, error){
					closeLoaderDialog();
					var msg = "Error! " + xhr.status + " " + error;
					$('#actionMessage').attr('class','errMess');
					$('#actionMessage').html(msg);
				}
			});
	});	
	
	$('a.down_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');		
		var prev_order = $(self).parents("td:first").children("input:nth-child(1)").val();		
		//sortAllOrder();
		$.ajax({
			 url: "<?php echo $this->url( array('module'=> 'Poll', 'controller' => 'backendanswer', 'action'     => 'down' ), 'adminrout',    true) ?>",
	 		 type: 'POST',
			 data: { id: arr[0], answer_order: prev_order},
			 beforeSend: function(){
				$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-animation.gif" border="0" />');
			 },
			 success: function(response) 
			 {
				//alert(response);
				var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					var new_order = parseInt(prev_order) + 1;
					$(self).parents("td:first").children("input:first").val(new_order);
					if(json_arr.id_arr != '' && json_arr.id_arr != null)
					{
						for(var i = 0; i < json_arr.id_arr.length; i++)
						{
							for(var j=0;j < $('a.up_btn').length ;j++)
							{
								var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');									
								if(arrUp[0] == json_arr.id_arr[i])	
								{										
									$('a.up_btn:eq('+j+')').parents("td:first").children("input:first").val(prev_order);
								}					
							}
						}							
					}						
				}
				$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif" border="0" />');
			 },
			error: function(xhr, status, error){
				closeLoaderDialog();
				var msg = "Error! " + xhr.status + " " + error;
				$('#actionMessage').attr('class','errMess');
				$('#actionMessage').html(msg);
			}
		});
	});
	
	$('a.update_poll_btn').click(function() {			
		sortAllOrder();	
		var formData = getFormData();
		formData.id = '<?php echo $this->id; ?>';
		
		$.ajax({
			url: "<?php echo $this->url( array('module' => 'Poll','controller' => 'backendpoll', 'action'     => 'edit' ), 'adminrout',    true) ?>",
			  	type: 'POST',
			  	data: formData,
				beforeSend: function(){						
						removeError();
						openLoaderDialog();				
					 },
				success: function(response){
					//alert(response);					
					var json_arr = eval("("+response+")");					
					closeLoaderDialog();
					if(json_arr.status == 'ok')
					{
						$('#actionMessage').html(succMsgDesign(json_arr.msg));						
						refreshCategoryTree();	
						if($("input[name='poll_answer[]']").length)
						{	
							open('<?php $pageHeader = (($_SERVER["HTTPS"] == "on")) ? "https://" : "http://" ; echo $pageHeader.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>','_parent');
						}
					}
					else if(json_arr.status == 'errV')
					{
						$('#actionMessage').html(errMsgDesign("<?php echo $this->translator->translator('common_err'); ?>"));
												
						for(var i= 0; i < json_arr.msg.length; i++)
						{
							addError(json_arr.msg[i].key,json_arr.msg[i].value);							
						}
					}
					else
					{
						$('#actionMessage').html(errMsgDesign(json_arr.msg));
					}
				},
				error: function(xhr, status, error){
					closeLoaderDialog();
					var msg = "Error! " + xhr.status + " " + error;
					$('#actionMessage').html(errMsgDesign(msg));
				}
		});
	});
	
	$('input.never_end').click(function() {			
		var disable = $('input#end_date').attr('disabled');
		if(disable)
		{
			$('input#end_date').removeAttr("disabled");
		}
		else
		{
			$('input#end_date').attr('disabled','disabled');
		}
	});
	
	function addDynamicField()
	{
		$('a.add_ans_btn').click(function() {
			var self = this;
			var spanId = parseInt($(self).attr('rel'));
			$(self).parents("span:first").remove();	
			var nextId = (spanId+1);
			var spanIdHtml = '<span>'+nextId+'.</span>&nbsp;&nbsp;';
			if(nextId > 9)
			{
				spanIdHtml = '<span>'+nextId+'.</span>';
			}
			var row = '<br/>'+spanIdHtml+'<input name="poll_answer[]" id="poll_answer'+spanId+'" value="" size="50" type="text" />';
			$("#add_data").append('<br />'+row+'<span class="select-btn" id="addMoreTitle'+spanId+'"><a href="javascript:void(0)" class="add_ans_btn" rel="'+nextId+'"><span class="icon add"><?php echo $this->translator->translator("poll_answer_add_new"); ?></a></span><span id="add_no_'+nextId+'"></span>&nbsp;</span>');
			addDynamicField();
		});
	}
	
	
/***********************************Get Poll Group***************************************/
	$('select.poll_select_group').change(function() {		
		$('#group_id_loader').html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" border="0" height="15" class="left-float"/>');
		var group_id = $('#group_id').val();
		if(group_id != '')
		{
			$('a.back_btn_link').attr('href','Poll/backendpoll/list/group_id/'+group_id);
			$.ajax({
				url: "<?php echo $this->url( array('module' => 'Poll','controller' => 'backend', 'action'     => 'pollgroup' ), 'adminrout',    true) ?>",
			  	type: 'POST',
			  	data: { grp_id: group_id },
				success: function(response){
					//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("poll_cat_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += json_arr.pollGroup+'</tbody></table>';
						$('#categoryTree').html(tree);
						categoryTreeGen();
					}
					else
					{
						var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("poll_cat_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
						$('#categoryTree').html(tree);
						categoryTreeGen();						
					}
					$('#group_id_err').html('');
					$('#group_id_loader').html('');
				}
			});
		}
		else
		{
			var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("poll_cat_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
				tree += '</tbody></table>';
			$('#categoryTree').html(tree);
			categoryTreeGen();
			$('#group_id_err').html('');
			$('#group_id_loader').html('');
			$('a.back_btn_link').attr('href','Poll/backendpro/list');
		}		
	});
	
	
});

/********************************Category Tree Function*******************************************/
function categoryTreeGen()
{
	$(".example").treeTable({
	  initialState: "expanded"
	});
	
	// Drag & Drop Example Code
	$("#dnd-example .file, #dnd-example .folder").draggable({
	  helper: "clone",
	  opacity: .75,
	  refreshPositions: true,
	  revert: "invalid",
	  revertDuration: 300,
	  scroll: true
	});
	
	
	$("#dnd-example .folder").each(function() {
	  $($(this).parents("tr")[0]).droppable({
		accept: ".file, .folder",
		drop: function(e, ui) { 
			var fieldObj = {};
			fieldObj.id	=	$(ui.draggable).parents("tr")[0].id;
			fieldObj.to	=	this.id;
			var url = "<?php echo $this->url( array('module' => 'Poll','controller' => 'backend', 'action'     => 'parent' ), 'adminrout',    true) ?>";
			$($(ui.draggable).parents("tr")[0]).postDataTo(this,fieldObj,url);
		  	$($(ui.draggable).parents("tr")[0]).appendBranchTo(this);
		},
		hoverClass: "accept",
		over: function(e, ui) {
		  if(this.id != $(ui.draggable.parents("tr.parent")[0]).id && !$(this).is(".expanded")) {
			$(this).expand();
		  }
		}
	  });
	});
	
	 $("#dnd-example .file").each(function() {
	  $($(this).parents("tr")[0]).droppable({
		accept: ".file, .folder",
		drop: function(e, ui) { 
		 	var fieldObj = {};
			fieldObj.id	=	$(ui.draggable).parents("tr")[0].id;
			fieldObj.to	=	this.id;
			var url = "<?php echo $this->url( array('module' => 'Poll','controller' => 'backend', 'action'     => 'parent' ), 'adminrout',    true) ?>";
			$($(ui.draggable).parents("tr")[0]).postDataTo(this,fieldObj,url);
			$($(ui.draggable).parents("tr")[0]).appendBranchTo(this);
		},
		hoverClass: "accept",
		over: function(e, ui) {
		  if(this.id != $(ui.draggable.parents("tr.parent")[0]).id && !$(this).is(".expanded")) {
			$(this).expand();
		  }
		}
	  });
	});
	
	// Make visible that a row is clicked
	$("table#dnd-example tbody tr").mousedown(function() {
	  $("tr.selected").removeClass("selected"); // Deselect currently selected rows
	  $(this).addClass("selected");
	});
	
	// Make sure row is selected when span is clicked
	$("table#dnd-example tbody tr span").mousedown(function() {
		var node_id = $(this).parents("tr")[0].id.substr(5);
		var node_name = $(this).html()+' ('+node_id+')';
		$('#category_id').val(node_id);
		$('#dataId').html(node_name);
	  $($(this).parents("tr")[0]).trigger("mousedown");
	});
}

/******************************** Refresh Poll Category Tree *******************************************/
function refreshCategoryTree()
{
	var group_id = $('#group_id').val();
	var category_parent = $('#category_id').val();
	if(group_id != '')
	{
		$.ajax({
			url: "<?php echo $this->url( array('module' => 'Poll','controller' => 'backend', 'action'     => 'categorytree' ), 'adminrout',    true) ?>",
			type: 'POST',
			data: { grp_id: group_id, parent : category_parent },
			success: function(response){				
				var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					var tree = '<table class="example" id="dnd-example">'+
									'<tbody ><tr id="node-0">'+
									 '<td>'+
										'<span class="folder">Root</span>'+
									'</td>'+
								'</tr>';
						tree += json_arr.categoryTree+'</tbody></table>';
					$('#categoryTree').html(tree);
					categoryTreeGen();
				}
				else
				{
					var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("poll_cat_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
					$('#categoryTree').html(tree);
					categoryTreeGen();
				}					
			}
		});
	}
	else
	{
		var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("poll_cat_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
		$('#categoryTree').html(tree);
		categoryTreeGen();			
	}	
}

/************************************************IMAGE THUMBNIL************************************************/
function imageThumbnil()
{	
	$("span.thumb").hover(function() {
		$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-110px',
				top: '50%',
				left: '50%',
				width: '174px', /* Set new width */
				height: '174px', /* Set new height */
				padding: '20px'
			}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '4px', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '30px', /* Set width back to default */
				height: '20px', /* Set height back to default */
				padding: '4px'
			}, 400);
	});
}

function getFileExtension(filename)
{
	return filename.replace(/^.*?\.([a-zA-Z0-9]+)$/, "$1");
}
</script>

<div id="container">
<?php if (!$this->allow()) : ?>
	<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
	</div>
<?php else : ?>

<div class="title-container">
	<div class="polls-list-edit"><h1><?php echo $this->translator->translator('poll_edit_page_name'); ?></h1></div>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Poll','controller' => 'backendpoll', 'action'     => 'list'), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="update_poll_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div class="content-container">
	<div id="sidebar-inner">
    	<div id="nav">
    		<div class="nav-header"><div class="nav-title"><?php echo $this->translator->translator('poll_cat_tree'); ?></div></div>
    		<div id="categoryTree" class="nav-body treebody" >
           		<?php echo $this->categoryTree; ?>
            </div>
       	</div>
    </div>
    
    <div id="content-inner">
    	<div id="actionMessage"></div>
        <div id="button_top_bar"></div>
        <form name="formCategory" id="formCategory" method="post">
        	<div id="generalInfo">
            <fieldset class="fieldset">
                <legend class="legend"><?php echo $this->translator->translator('poll_edit_page_info'); ?></legend>
                <div class="form">
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->question->getLabel();  if($this->pollForm->question->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->question; ?>
                            <div class="input-errors" id="question_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->question_title->getLabel();  if($this->pollForm->question_title->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->question_title; ?>
                            <div class="input-errors" id="question_title_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->group_id->getLabel();  if($this->pollForm->group_id->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <div class="left-float"><?php echo $this->pollForm->group_id; ?></div><span id="group_id_loader"></span>
                            <div class="input-errors" id="group_id_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->category_id->getLabel(); ?>
                        </div>
                        
                        <div class="field field-big">
                            <span id="dataId"><?php echo $this->escape($this->category_name)." (".$this->pollForm->category_id->getValue().")"; ?></span><?php echo $this->pollForm->category_id; ?>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->thumb->getLabel();  if($this->pollForm->thumb->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                        	<div class="upload-img">
                            	<span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="upload_btn" rel="poll_file"><span class="icon upload"><?php echo $this->translator->translator('common_upload'); ?></span></a></span>
                            	<div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pollForm->thumb->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                            </div> 
                            <?php echo $this->pollForm->thumb; ?>&nbsp;&nbsp;<span id="selected_file_thumb"><?php if($this->thumb){ ?><div class="upload-img box"><span><span class="thumb"><img src="data/frontImages/poll/poll_thumb/<?php echo $this->thumb; ?>" width="45" height="35" class="bdr" /></span><br /><br /><a href="javascript:void(0)" class="delete_image_lnk" rel="<?php echo $this->thumb; ?>"><?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;</span></div><?php } ?></span>
                            <div class="input-errors" id="thumb_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->start_date->getLabel();  if($this->pollForm->start_date->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->start_date; ?>
                            <div class="input-errors" id="start_date_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->end_date->getLabel();  if($this->pollForm->end_date->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php 
								if($this->pollForm->never_end->getValue())
								{	
									$this->pollForm->end_date->setAttrib('disabled','disabled');
									$this->pollForm->end_date->setAttrib('rel','1');				  
								}
								echo $this->pollForm->end_date; 
								echo ' &nbsp;&nbsp; '.$this->pollForm->never_end; echo $this->pollForm->never_end->getLabel();
							?>
                            <div class="input-errors" id="end_date_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->multiple_option->getLabel();  if($this->pollForm->multiple_option->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->multiple_option; ?>
                            <div class="input-errors" id="multiple_option_err"></div>
                        </div>
                    </div>
                    
                    <?php
						$count = 0;
						$mem_db = new Members_Model_DbTable_MemberList();
						$answer_percentage = new Poll_View_Helper_PollAnswerPercentage();
					?>
                    <div class="form-row">
                        <div class="label label-small">
                            Answers:
                        </div>
                        
                        <div class="field field-big">
                        	<div class="chart">
								<div class="data-table">
                        			<table id="sortTable" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                        <thead>
                                            <tr>
                                                <th width="31%"><?php echo $this->translator->translator('poll_poll_list_answer'); ?> </th>
                                                <th width="9%"><?php echo $this->translator->translator('poll_poll_list_answer_vote'); ?></th>
                                                <th width="13%">
                                                    <?php echo $this->translator->translator('common_order'); ?>
                                                    <a href="javascript: void(0);" class="all_order_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" /></a>
                                                </th>
                                                <th width="15%"><?php echo $this->translator->translator('common_date'); ?></th>
                                                <th width="10%"><?php echo $this->translator->translator('common_status'); ?></th>
                                                <th width="22%"><?php echo $this->translator->translator('common_action'); ?></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php			
                                            foreach($this->answers_result as $answer)
                                            {
                                        ?>
                                            <tr>
                                                <td>
                                                    <?php 	
                                                        echo $this->escape($answer->content);
                                                        $member_info = $mem_db->getMemberInfo($this->escape($answer->entry_by));
                                                    ?>
                                                </td>
                                                <td class="center">
                                                    <?php 	
                                                        if($answer->active)
                                                        {
                                                            $percentage = $answer_percentage->getPercentage($this->id,$answer->num_views);
                                                        }
                                                        else
                                                        {
                                                            $percentage = 0;
                                                        }
                                                        echo $percentage.'%';
                                                    ?>
                                                </td>
                                                <td class="center">
                                                    <input type="text" size="1" name="answer_order" id="answer_order" class="answer_order_text" value="<?php echo $this->escape($answer->answer_order); ?>" />
                                                    <a href="javascript: void(0);" rel="<?php echo $this->escape($answer->id); ?>" class="up_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" /></a>&nbsp;<a href="javascript: void(0);" rel="<?php echo $this->escape($answer->id); ?>" class="down_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif" border="0" /></a>    
                                                </td>
                                                <td class="center" title="<strong><?php echo $this->translator->translator('common_date'); ?> : </strong><?php echo $this->escape($answer->created_date); ?><br /><strong><?php echo $this->translator->translator('common_entry'); ?> : </strong> <?php echo $this->escape($member_info['username']); ?>"><?php echo strftime('%Y-%m-%d',strtotime($this->escape($answer['created_date']))); ?></td>
                                                <td class="center"><?php if($this->escape($answer->active) == '1'){ echo $this->translator->translator('common_published_language'); }else{ echo $this->translator->translator('common_unpublished_language'); }  ?></td>
                                              
                                                <td class="tools-list">
                                                    <ul>
                                                        <li>
                                                            <?php if ($this->allow('edit','backendanswer','Poll')) : ?>
                                                            <a href="javascript:void(0);" class="edit_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/edit.png" title="<?php echo $this->translator->translator('common_edit_title'); ?>"  border="0" /></a>
                                                            <a href="javascript:void(0);" class="save_btn"  style="display:none;" rel="<?php echo $this->escape($answer->id); ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/save.gif" alt="Save" title="<?php echo $this->translator->translator('common_save_title'); ?>"  border="0"/></a><a href="javascript:void(0);" class="cancel_btn"  style="display:none;" rel="<?php echo $this->escape($answer->id); ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/cancel.gif" alt="Cancel" title="<?php echo $this->translator->translator('common_cancel_title'); ?>" border="0"/></a>
                                                            <?php endif; ?>
                                                        </li>
                                                        <li>
                                                            <?php if ($this->allow('delete','backendanswer','Poll')) : ?>
                                                            <a href="javascript:void(0);" class="delete_btn"  rel="<?php echo $this->escape($answer->id);?>_<?php echo $this->escape($answer->answer_order);?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/delete.png" title="<?php echo $this->translator->translator('common_delete_title'); ?>"  border="0" /></a>
                                                            <?php endif; ?>
                                                        </li>
                                                        <li>
                                                            <?php if ($this->allow('publish','backendanswer','Poll')) : ?>
                                                            <a href="javascript:void(0);" class="publish_btn" rel="<?php echo $this->escape($answer->id); ?>_<?php if($this->escape($answer->active) == '1'){ ?>unpublish<?php }else{ ?>publish<?php } ?>"><?php if($this->escape($answer->active) == '1'){ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator('common_unpublish_title'); ?>" /><?php }else{ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator('common_publish_title'); ?>" /><?php } ?></a>
                                                            <?php endif; ?>
                                                        </li>
                                                    </ul>
                                                </td>
                                            </tr>		 
                                        <?php
                                            }
                                        ?>
                                        </tbody>
									</table>
                            	</div>
							</div>
                            
                            <div id="add_more">
                            	<span class="select-btn" id="addMoreTitle"><a href="javascript:void(0)" class="add_ans_btn" rel="<?php echo $this->last_order;?>"><span class="icon add"><?php echo $this->translator->translator("poll_answer_add_new"); ?></span></a></span>
								<span id="add_data">&nbsp;</span>
                            </div>
                        </div>
                    </div>
				</div>
			</fieldset>
            </div>
            
            <fieldset class="fieldset last">
                <legend class="legend"><?php echo $this->translator->translator('common_metainfo_title'); ?></legend>
                <div class="form">
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->meta_title->getLabel();  if($this->pollForm->meta_title->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->meta_title; ?>
                            <div class="input-errors" id="meta_title_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->meta_keywords->getLabel();  if($this->pollForm->meta_keywords->isRequired()){ ?><span class="required">*</span><?php }?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->meta_keywords; ?>
                            <div class="input-errors" id="meta_keywords_err"></div>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="label label-small">
                            <?php echo $this->pollForm->meta_desc->getLabel();  if($this->pollForm->meta_desc->isRequired()){ ?><span class="required">*</span><?php }?>
                        </div>
                        
                        <div class="field field-big">
                            <?php echo $this->pollForm->meta_desc; ?>
                            <div class="input-errors" id="meta_desc_err"></div>
                        </div>
                    </div>
				</div>
			</fieldset>
        </form>
	</div>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Poll','controller' => 'backendpoll', 'action'     => 'list'), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="update_poll_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div id="floatingbar">
	<h1><?php echo $this->translator->translator('poll_edit_page_name'); ?></h1>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Poll','controller' => 'backendpoll', 'action'     => 'list'), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="update_poll_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>
<?php endif; ?>

<div id="dialog-confirm" title="<?php echo $this->translator->translator('common_confirmation', $this->translator->translator('common_delete')); ?>"></div>
<div id="dialog_container" style="display:none" title="<?php echo $this->translator->translator('common_dialog_msg', $this->translator->translator('poll_edit_page_name')); ?>">
	<div id="progressbar" ></div>	
</div>
<div id="upload-form" title="<?php echo $this->translator->translator('poll_page_dialog'); ?>">	
	<div>
    	<form id="popupForm" target="i-upload-form" method="post" action="" >
            <input type="hidden" name="table_name" value="poll_group"/>
            <input type="hidden" name="primary_id_field" value="id"/>
            <input type="hidden" name="primary_id_field_value" value=""/>   
            <input type="hidden" name="primary_file_field" value="thumb"/> 
           	<input type="hidden" name="file_content"  value=""/>       
            <input type="hidden" name="file_path_field" value="file_path_thumb"/>
            <input type="hidden" name="file_extension_field" value="file_type"/>
            <input type="hidden" name="file_max_size_field" value="file_size_max"/>
    	</form>
    	<iframe id="i-upload-form" name="i-upload-form" src="" class="iframe-img-upload"></iframe>
    </div>        
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="javascript:void(0);" class="select_file_btn"><span class="icon insert"><?php echo $this->translator->translator('poll_page_insert'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:void(0);" class="close_dialog_btn"><span class="icon close"><?php echo $this->translator->translator('common_close'); ?></span></a></span>
    </div>
</div>
</div>